package demo1;

class Shape{
    public void draw(){
        System.out.println("画图形！");
    }
}
class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("画矩形！");
    }
}
class Cycle extends Shape{
    @Override
    public void draw() {
        System.out.println("画圆！");
    }
}
class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("画三角形！");
    }
}

public class Test {

    public static void drawMap(Shape shape){
//        shape.draw();

        Shape[] shapes = {new Cycle(),new Rect(),new Triangle()};
        for (Shape s : shapes){
            s.draw();
        }
    }


    public static void main(String[] args) {
        /*Shape rect = new Rect();
        drawMap(rect);*/

        drawMap(new Cycle());

        drawMap(new Triangle());
    }
}
